package com.bingfor.easycablelink.product;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.bingfor.easycablelink.R;
import com.bingfor.easycablelink.databinding.ItemLogisticalListBinding;
import com.bingfor.easycablelink.home.Fragment.Cable.CableItemAdapter;
import com.bingfor.easycablelink.product.ProductDetailsActivity;
import com.bingfor.easycablelink.widgets.BannerLayout;

import java.util.List;

/**
 * Created by LY on 2017/5/23.
 */

public class QuotationItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    public QuotationItemAdapter() {
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

            return new LogisticalItemViewHolder(
                    ItemLogisticalListBinding
                            .inflate(LayoutInflater.from(parent.getContext()), parent, false)
                            .getRoot());

    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

        ItemLogisticalListBinding binding = DataBindingUtil.findBinding(holder.itemView);
        binding.getRoot().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                v.getContext().startActivity(new Intent(v.getContext(), ProductDetailsActivity.class));
            }
        });

    }

    @Override
    public int getItemCount() {
        return 4;
    }

    public class LogisticalItemViewHolder extends RecyclerView.ViewHolder {
        LinearLayout mContain;
        CableItemAdapter cableItemAdapter = new CableItemAdapter();
        public LogisticalItemViewHolder(View itemView) {
            super(itemView);

        }
    }

    public class TopViewHolder extends RecyclerView.ViewHolder {
        BannerLayout bannerLayout;

        public TopViewHolder(View itemView) {
            super(itemView);
            bannerLayout = (BannerLayout) itemView.findViewById(R.id.mBannerLayout);
        }
    }

    public void setUrls(List<String> urls) {
        notifyDataSetChanged();
    }

    @Override
    public int getItemViewType(int position) {
        return position;
    }

}
